package com.foreknow.springboot.threaddemo;

public class Thread1 implements Runnable{

    @Override
    public void run() {
        synchronized (WaitAndSleep.class){
            System.out.println("enter Thread1......");
            System.out.println("Thread1 is waiting......");
            try {
                //调用wait方法，线程会放弃对象锁，进入等待此对象的锁定池中
                WaitAndSleep.class.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Thread1 is going on......");
            System.out.println("Thread1 is over......");

        }
       }
}
